
public class NSquare {

	/**
	 * Write a function to check if an integer is square or not? Ex, 49 is square, 48 is not.
	 */
	public static void main(String[] args) {
		
		System.out.println(checkSquare(49));

	}

	private static boolean checkSquare(int n) {
		
		boolean result = false;
		
		if (n == 2 || n == 1) {
			return true;
		}
		
		int l = 0;
		int r = n/2;
		while (l <= r) {
			int m = (l+r) >> 1;
			if(m*m == n) {
				result = true;
				break;
			} else {
				if (m * m > n) {
					r = m - 1;
				} else {
					l = m + 1;
				}
			}
		}
		
		return result;
	}

}
